<div class="orders index">
        <h2><?php echo $html->image('iconos/orders.png'); __('Pedidos');?></h2>
        <div class="actions specific">
	<ul>
<!--		<li><?php echo $this->Html->link(__('New Order', true), array('action' => 'add')); ?></li>-->
            <li><?php echo $this->Html->link(__('Pedidos S/Confirmar', true), array('controller' => 'orders', 'action' => 'listapdf')); ?> </li>
	</ul>
</div>
	<table cellpadding="0" cellspacing="0">
	<tr>
<!--			<th><?php echo $this->Paginator->sort('Id','id');?></th>-->
			<th><?php echo $this->Paginator->sort('Fecha Emision','date');?></th>
			<th><?php echo $this->Paginator->sort('Cantidad','amount');?></th>
			<th><?php echo $this->Paginator->sort('Articulo','article_id');?></th>
			<th><?php echo $this->Paginator->sort('Proveedor','supplier_id');?></th>
			<th><?php echo $this->Paginator->sort('Fecha Recibido','date_recibed');?></th>
			<th><?php echo $this->Paginator->sort('Cantidad Recibida','amount_recibed');?></th>
			<th class="actions"><?php __('Opciones');?></th>
	</tr>
	<?php
	$i = 0;
	foreach ($orders as $order):
		$class = null;
		if ($i++ % 2 == 0) {
			$class = ' class="altrow"';
		}
        //me fijo si tiene una cantidad es distinta que la recibida
        if((!empty($order['Order']['amount_recibed'])) and ($order['Order']['amount'] > $order['Order']['amount_recibed'])){
            $class = ' class="out_stock"';
        }
	?>
	<tr<?php echo $class;?>>
<!--		<td><?php echo $order['Order']['id']; ?>&nbsp;</td>-->
		<td><?php
                $fecha = date('d/m/Y', strtotime($order['Order']['date']));
                echo $fecha; ?>&nbsp;</td>
		<td><?php echo $order['Order']['amount']; ?>&nbsp;</td>
		<td>
			<?php echo $this->Html->link($order['Article']['mark'] . '-' . $order['Article']['model'], array('controller' => 'articles', 'action' => 'view', $order['Article']['id'])); ?>
		</td>
		<td>
			<?php echo $this->Html->link($order['Supplier']['name'], array('controller' => 'suppliers', 'action' => 'view', $order['Supplier']['id'])); ?>
		</td>
		<td><?php
                if($order['Order']['date_recibed'] != NULL){
                $fecha = date('d/m/Y', strtotime($order['Order']['date']));
                echo $fecha;    
                }else{
                echo $order['Order']['date_recibed']; 
                }
                ?>&nbsp;</td>
		<td><?php echo $order['Order']['amount_recibed']; ?>&nbsp;</td>
		<td class="actions">
			<?php
                        if($order['Order']['date_recibed'] == NULL){
                            echo $this->Html->link(__('Confirmar', true), array('action' => 'confirm', $order['Order']['id']));
                        }
                        ?>
			<?php echo $this->Html->link(__('Ver', true), array('action' => 'view', $order['Order']['id'])); ?>
			<?php echo $this->Html->link(__('Editar', true), array('action' => 'edit', $order['Order']['id'])); ?>
			<?php echo $this->Html->link(__('Eliminar', true), array('action' => 'delete', $order['Order']['id']), null, sprintf(__('Esta seguro que desea eliminar # %s?', true), $order['Order']['id'])); ?>
		</td>
	</tr>
<?php endforeach; ?>
	</table>
	<p>
	<?php
	echo $this->Paginator->counter(array(
	'format' => __('Página %page% de %pages%, mostrando %current% registros de %count% en total, a partir del registro %start%, terminando en el %end%', true)
	));
	?>	</p>

	<div class="paging">
		<?php echo $this->Paginator->prev('<< ' . __('previous', true), array(), null, array('class'=>'disabled'));?>
	 | 	<?php echo $this->Paginator->numbers();?>
 |
		<?php echo $this->Paginator->next(__('next', true) . ' >>', array(), null, array('class' => 'disabled'));?>
	</div>
</div>